package com.runchinaup.smartbelt;

import android.app.Application;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;

import com.runchinaup.smartbelt.receiver.MyPhoneStateListener;
import com.tencent.bugly.crashreport.CrashReport;

/**
 * Created by liber on 2018/1/18.
 */

public class App extends Application {

    public static App app;

    public static App getApp() {
        return app;
    }

    private TelephonyManager manager;

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        CrashReport.initCrashReport(getApplicationContext(), "06aa322d91", false);
        //监听来电
        OnCallListener();
    }

    private void OnCallListener() {
        manager = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
        // 手动注册对PhoneStateListener中的listen_call_state状态进行监听
        manager.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
    }
}
